package com.lzx.paymentServer.controller;


import com.lzx.commons.entity.Payment;
import com.lzx.commons.entity.Result;
import com.lzx.commons.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import com.lzx.paymentServer.service.PaymentService;

import javax.annotation.Resource;

@RestController
@RequestMapping("/payment")
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    @Resource
    private PaymentService paymentService;

    @GetMapping("/get")
    public Result get(@RequestParam("id") Integer id){
        Assert.notNull(id,"id is not not");
        return ResultUtil.customResultParam("200","success:"+serverPort,paymentService.getById(id));
    }

    @PostMapping("/save")
    public Result save(@RequestBody Payment payment){
        return ResultUtil.customResultParam("200","success:"+serverPort,paymentService.save(payment));
    }


}
